package lanqiao13;

import java.util.Scanner;

public class D {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] nums = new int[n];
		for (int i = 0; i < nums.length; i++) {
			nums[i] = scan.nextInt();
		}
		scan.close();
		int min = n;
		
		int[] nums1 = new int[31];
		for (int i = 1; i <= 1000000; i++) {
			int temp = 0;
			nums1[0] = i;
			nums1[1] = i;
			if (nums[0] != i) {
				temp++;
			}
			if (nums[1] != i) {
				temp++;
			}
			int j;
			for (j = 2; j < nums.length; j++) {
				nums1[j] = nums1[j-1] + nums1[j-2];
				if (nums[j] != nums1[j]) {
					temp++;
				}
				if (nums1[j] > 1000000) {
					min = Math.min(min, n - (j + 1 - temp));
					break;
				}
			}
			
			if (j == n) {
				min = Math.min(min, temp);
			}
		}
		System.out.println(min);
	}
}
